package com.ruoyi.bizsys.service.impl;

import java.util.List;
import java.util.Arrays;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.stereotype.Service;
import com.ruoyi.bizsys.mapper.RuleInMapper;
import com.ruoyi.bizsys.domain.RuleIn;
import com.ruoyi.bizsys.service.IRuleInService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;


/**
 * 规则调用记录Service业务层处理
 *
 * @author african-loan
 * @date 2021-12-30
 */
@Service
public class RuleInServiceImpl extends ServiceImpl<RuleInMapper, RuleIn> implements IRuleInService {

    /**
     * 查询规则调用记录
     *
     * @param id 规则调用记录ID
     * @return 规则调用记录
     */
    @Override
    public RuleIn selectRuleInById(Long id) {
        return this.getById(id);
    }

    /**
     * 查询规则调用记录列表
     *
     * @param ruleIn 规则调用记录
     * @return 规则调用记录
     */
    @Override
    public List<RuleIn> selectRuleInList(RuleIn ruleIn) {
        return this.list(new QueryWrapper<>(ruleIn).last("order by id desc"));
    }

    /**
     * 新增规则调用记录
     *
     * @param ruleIn 规则调用记录
     * @return 结果
     */
    @Override
    public int insertRuleIn(RuleIn ruleIn) {
        ruleIn.setCreateTime(DateUtils.getNowDate());
        return baseMapper.insert(ruleIn);
    }

    /**
     * 修改规则调用记录
     *
     * @param ruleIn 规则调用记录
     * @return 结果
     */
    @Override
    public int updateRuleIn(RuleIn ruleIn) {
        ruleIn.setUpdateTime(DateUtils.getNowDate());
        return baseMapper.updateById(ruleIn);
    }

    /**
     * 批量删除规则调用记录
     *
     * @param ids 需要删除的规则调用记录ID
     * @return 结果
     */
    @Override
    public int deleteRuleInByIds(Long[] ids) {
        return baseMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除规则调用记录信息
     *
     * @param id 规则调用记录ID
     * @return 结果
     */
    @Override
    public int deleteRuleInById(Long id) {
        return baseMapper.deleteById(id);
    }

}
